package com.wyt.service.impl;

import com.wyt.dao.mapper.AbilitiesMapper;
import com.wyt.dao.mapper.LikesMapper;
import com.wyt.dao.mapper.UsersMapper;
import com.wyt.pojo.ResLikeVO;
import com.wyt.service.ClickLikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ClickLikeServiceImpl implements ClickLikeService {

    @Autowired
    private LikesMapper likesMapper;

    @Autowired
    private UsersMapper usersMapper;

    @Autowired
    private AbilitiesMapper abilitiesMapper;

    @Override
    public ResLikeVO ClickLike(int user_id, int ability_id) {
        ResLikeVO resLikeVO = new ResLikeVO();

        likesMapper.changeStatus(user_id,ability_id);

//        if(likesMapper.queryLikeStatus(user_id, ability_id)){
//            likesMapper.initLikes(user_id, ability_id,1);
//        }else {
//            likesMapper.changeStatus(user_id,ability_id);
//        }

        resLikeVO.setUserId(user_id);
        resLikeVO.setUserName(usersMapper.queryName(user_id));
        resLikeVO.setAbilityId(ability_id);
        resLikeVO.setAbilityName(abilitiesMapper.queryName(ability_id));
        resLikeVO.setLikeStatus(likesMapper.queryLikeStatus(user_id,ability_id));

        return resLikeVO;
    }

}
